package com.softvan.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageInfo;
import com.softvan.bean.CityBean;
import com.softvan.entity.City;
import com.softvan.service.CityService;

@RestController
@RequestMapping("/city")
public class CityController {
    @Autowired
    private CityService cityService;
    
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Autowired
    private RedisTemplate redisTemplate;

    @RequestMapping("/bean")
    public PageInfo<CityBean> getAll(CityBean city) {
        stringRedisTemplate.opsForValue().set("aaa", "111");
        System.out.println(stringRedisTemplate.opsForValue().get("aaa"));
        city.setPage(3);
        city.setRows(2); 
        List<CityBean> countryList = cityService.getAll(city);
        return new PageInfo<CityBean>(countryList);
    }
    
    @RequestMapping("/entity")
    public PageInfo<City> getAll(City city) {
        city.setPage(2);
        city.setRows(1);
        List<City> countryList = cityService.findAll(city);
        return new PageInfo<City>(countryList);
    }
}
